package four.book.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import four.book.entity.BookUser2;

/**
@author 李志
@version 1.0
<p>日期：2018年12月19日 下午2:48:34</p>
*/
public class InterceptorUser extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		HttpSession session=request.getSession();
		BookUser2 user=(BookUser2)session.getAttribute("USER");
		String load=request.getServletContext().getContextPath();
		if(user==null){
			response.sendRedirect(load+"/User/toLogin.do");
			return false;
		}
		return  true;
	}

	 

}
